var $appData={
  'baseUrl':"http://localhost:8080/",
  'msg':{
    'error':"系统错误",
  }
};
$(function() {
  //toastr配置
  toastr.options = {
      "closeButton": false,
      "debug": false,
      "newestOnTop": false,
      "progressBar": false,
      "positionClass": "toast-top-center",
      "preventDuplicates": false,
      "onclick": null,
      "showDuration": "300",
      "hideDuration": "1000",
      "timeOut": "3000",
      "extendedTimeOut": "1000",
      "showEasing": "swing",
      "hideEasing": "linear",
      "showMethod": "fadeIn",
      "hideMethod": "fadeOut"
  };
  auth();
  $("#login-out").click(function(){
      loginOut();
  });

  $(".tpl-left-nav-menu a").on("click",function(){
    var self = $(this);
    var link = self.attr("link-data");
    // $("#page").attr("src",link);
    togglePage(link);
    $(".tpl-left-nav-menu a").removeClass("active");
    self.addClass("active");
    //console.log(this);
  });
   //读取body data-type 判断是哪个页面然后执行相应页面方法，方法在下面。
  var dataType = $('body').attr('data-type');
  for (key in pageData) {
   if (key == dataType) {
     pageData[key]();
   }
 }

});

// 页面数据
var pageData={
  // ===============================================
  // 登陆
  // ===============================================
  'login':function(){
    $("#login").click(function(){
      var validata = $appTools.validator("#login-form");
      if(validata){
        var userTypeData = ['student','teacher','admin','secretary'];
        $.ajax({
          'url':$appData.baseUrl+"/usr/signin",
          'type':'get',
          'dataType':'json',
          'data':$("#login-form").serialize(),
          success:function(res){
            if(res.result==null){
              toastr.error("账号或密码不正确!");
            }else{
              toastr.options.onShown=function(){
                $appTools.setCookie("userType", userTypeData[res.result.userType]);
                $appTools.setCookie("nickname", res.result.nickname);
                $appTools.setCookie("username", res.result.username);
                $appTools.setCookie("userId", res.result.id);
                location.href = $appData.baseUrl+"index";
              };
              toastr.success("登陆成功");
            }
            //console.log(res);
          },
          error:function(res){
            toastr.error($appData.msg.error);
          }

        });
      }
    });

  },
  // ===============================================
  // 首页
  // ===============================================
  'index':function(){
    togglePage("main");
    $("#nickname").html($appTools.getCookie("nickname"));
  },
  'major':function(){
    getDataList("dataListTpl","major/list",0);
    addData("/major/new","dataListTpl","major/list");
  },
  'studenList':function(){
    getDataList("studentdataListTpl","stu/list",0);
    importData("/stu/new/upload","studentdataListTpl","stu/list");
    majorSelect();
    addData("/stu/new","studentdataListTpl","stu/list");
    $(".select-option").change(function() {
      $("input[name='"+this.getAttribute("select-id")+"']").val(this.value);
      var isSelect = $("input[name='isSelect']").val();
      var majorId = $("input[name='majorId']").val();
      var isSelectSuccess = $("input[name='isSelectSuccess']").val();
      var url ="stu/list?";
      if(isSelect!="all"){
        url = url+"isSelect="+isSelect;
      }
      if(majorId!="all"){
        url = url+"&majorId="+majorId;
      }
      if(isSelectSuccess!='all'){
        url = url+"&isSelectSuccess="+isSelectSuccess;
      }
      getDataList("studentdataListTpl",url,0);
    });
    $("#search-submit").unbind().click(function(){
      var search = $("#search-input").val();
      searchData("studentdataTpl","stu/get/um/"+search);
    });
  },
  'teacherList':function(){
    getDataList("teacherdataListTpl","teac/list",0);
    importData("/teac/new/upload","teacherdataListTpl","teac/list");
    $("#search-submit").unbind().click(function(){
      var search = $("#search-input").val();
      searchData("teacherdataTpl","teac/get/um/"+search);
    });
    addData("/teac/new","teacherdataListTpl","teac/list");
  },
  'studentPaper':function (){
    var id=$appTools.getUrlParam("id");
    var name = $appTools.getUrlParam("name");
    $("#title-name").text(name);
    getDataList("studentPaperdataListTpl",'selection/list/stu?studentId='+id,0,null,'该学生还没有选题');
  },
  'teacherPaper':function (){
    var id=$appTools.getUrlParam("id");
    var name = $appTools.getUrlParam("name");
    $("#title-name").text(name);
    getDataList("teacherPaperdataListTpl",'/subject/list?teacherId='+id,0,null,'该老师还没有发布选题');
  },
  'paperList':function(){
    getDataList("paperdataListTpl","subject/list",0);
    majorSelect();
    $(".select-option").change(function() {
      $("input[name='"+this.getAttribute("select-id")+"']").val(this.value);
      var isSelect = $("input[name='isSelect']").val();
      var majorId = $("input[name='majorId']").val();
      var url ="subject/list?";
      if(isSelect!="all"){
        url = url+"isSelect="+isSelect;
      }
      if(majorId!="all"){
        url = url+"&majorId="+majorId;
      }
      getDataList("paperdataListTpl",url,0);
    });
    $("#search-submit").unbind().click(function(){
      var search = $("#search-input").val();
      searchData("paperdataListTpl","subject/list?titleLike="+search);
    });
    auth();
    $("#add").unbind().click(function(){
      go("paper/add");
    })
  },
  'paperStudent':function(){
    var id=$appTools.getUrlParam("id");
    var name = $appTools.getUrlParam("title");
    $("#subject-id").val(id);
    $("#title-name").text(name);
    getDataList("paperStudentdataListTpl",'/stu/sub/list/'+id,0,null,'该选题还没有学生选择');
  },
  'paperDetail':function(){
    var id=$appTools.getUrlParam("id");
    //var id = 'f18e2edf6098230601609823b8840000';
    $.ajax({
      url:$appData.baseUrl+"subject/get/"+id,
      success:function(res){
        $("#title").html(res.result.title);
        $("#teacher").html(res.result.teacher.nickname);
        $("#description").html(res.result.description);
      }
    });
  },
  'addPaper':function(){
    KindEditor.ready(function(K) {
         window.editor = K.create('#editor',{
           uploadJson : $appData.baseUrl+'/usr/upload',
         });
   });
   majorSelect();
   $("#add-sumbit").click(function(){
     var title = $("input[name='title']").val();
     var description = window.editor.html();
     var major = $("select[name='majorId']").val();
     if($appTools.isEmpty(title)){
       toastr.error("标题不能为空");
       return;
     }

     if($appTools.isEmpty(description)){
       toastr.error("内容不能为空");
       return;
     }

     if($appTools.isEmpty(major)){
       toastr.error("请选择专业");
       return;
     }

     $.ajax({
       url:$appData.baseUrl+"/subject/new",
       data:{
         'title':title,
         'description':description,
         'majorId':major,
         'offer':3,
       },
       success:function(res){
         if(res.msg=='ok'){
           toastr.success("添加成功");
         }else{
           toastr.error("添加失败");
         }
       },
       error:function(){
         toastr.error($appData.msg.error);
       }
     })
   });
  },
  'editPaper': function(){
   var id=$appTools.getUrlParam("id");
   var number;


   KindEditor.ready(function(K) {
         window.editor = K.create('#editor',{
           uploadJson : $appData.baseUrl+'/usr/upload',
         });
         //var id = 'f18e2edf6098230601609823b8840000';
         $.ajax({
           url:$appData.baseUrl+"subject/get/"+id,
           success:function(res){
             $("input[name='title']").val(res.result.title);
             window.editor.html(res.result.description);
             console.log(res.result.description);
             number = res.result.number;
             majorSelect(res.result.major.id);
           }
         });
   });

   $("#edit-sumbit").click(function(){
     var title = $("input[name='title']").val();
     var description = window.editor.html();
     var major = $("select[name='majorId']").val();
     if($appTools.isEmpty(title)){
       toastr.error("标题不能为空");
       return;
     }

     if($appTools.isEmpty(description)){
       toastr.error("内容不能为空");
       return;
     }

     if($appTools.isEmpty(major)){
       toastr.error("请选择专业");
       return;
     }

     $.ajax({
       url:$appData.baseUrl+"/subject/update",
       data:{
         'title':title,
         'description':description,
         'majorId':major,
         'offer':3,
         'id':id,
         'number':number,
       },
       success:function(res){
         if(res.msg=='ok'){
           toastr.success("更新成功");
         }else{
           toastr.error("添加失败")
         }
       },
       error:function(){
         toastr.error($appData.msg.error);
       }
     });
   });
 },
 'select':function(){
   $appTools.setCookie("isSelectSuccess",'false');
   $.ajax({
     url:$appData.baseUrl+"selection/list/stu",
     data:{
       'size':10,
       'page':0,
     },
     type:'post',
     dataType:'json',
     success:function(res){
       if(res.result.length!=0){
         var status = 0;
         for(var i=0;i<res.result.length;i++){
           if(res.result[i].status==1){
             status=1;
           }
         }
         if(status==1){
           $appTools.setCookie("isSelectSuccess",'true');
         }
         var dataList = template('stuSubListTpl',res.result);
         $("#data-list").html(dataList);
       }else{
         $("#subList").hide();
         $("#subInfo").show();
       }
     }
   });
   //alert(123);
   $.ajax({
      url:$appData.baseUrl+"/teac/list",
      data:{
        'size':100,
        'page':0,
      },
      dataType:'json',
      success:function(res){
        var dataList = template('teacSelectListTpl',res.result.content);
        $("#teacherList").html(dataList);
        getDataList('subListTpl','subject/list?teacherId='+res.result.content[0].id,0,"sub-list");
      }
    });
 },
 'errorInfo':function(){
   var msg=$appTools.getUrlParam("msg");
   $("#msg").text(msg);
 },
 'selectStudent':function(){
   var mid=$appTools.getUrlParam("mid");
   var sid=$appTools.getUrlParam("sid");
   $("input[name='subjectId']").val(sid);
   if($appTools.getCookie("userType")=="admin"){
     majorSelect(mid);
     $(".select-option").change(function() {
       $("input[name='"+this.getAttribute("select-id")+"']").val(this.value);
       var majorId = $("input[name='majorId']").val();
       var url ="stu/list?isSelectSuccess=false";
       if(majorId!="all"){
         url = url+"&majorId="+majorId;
       }
       getDataList("selectStudentdataListTpl",url,0);
     });
     getDataList("selectStudentdataListTpl","stu/list?isSelectSuccess=false&majorId="+mid,0);
   }else{
     $("#search-div").removeClass("am-u-md-9");
     $("#search-div").addClass("am-u-md-12");
   }

   $("#search-submit").unbind().click(function(){
     var search = $("#search-input").val();
     searchData("studentdataTpl","stu/get/um/"+search);
   });

 },
 'account':function(){
   $("input[name='username']").val($appTools.getCookie("username"));
    $("input[name='nickname']").val($appTools.getCookie("nickname"));
    $("input[name='id']").val($appTools.getCookie("userId"));
    $("#update-submit").click(function(){
      var validata = $appTools.validator("#update-form");
      if(validata){
        if($("#password").val()!=$("#isPassword").val()){
          toastr.error("两次密码不一致");
          return;
        }
        $.ajax({
          'url':$appData.baseUrl+"/usr/update/pwd",
          'type':'get',
          'dataType':'json',
          'data':$("#update-form").serialize(),
          success:function(res){
            if(res.result==1){
              toastr.options.onShown=function(){
                loginOut();
              }
              toastr.success("修改成功,请重新登录");

            }else{
              toastr.error(res.result);
            }
          },
          error:function(){
            toastr.error($appData.msg.error);
          }
        });
      }
    });
 }

};
//权限控制
function auth(){
  $(".auth-show").each(function(){
    var self = $(this);
    var authData = self.attr("auth-data");
    var userType = $appTools.getCookie("userType");
    if(authData.indexOf(userType)!=-1){
      self.show();
    }
  });
}
//退出登录
function loginOut(){
  //$("#login-out").click(function(){
    $.ajax({
      url:$appData.baseUrl+"usr/signout",
      dataType:'json',
      async: false,
      success:function(res){
        toastr.options.onShown=function(){
          $appTools.delCookie("userType");
          $appTools.delCookie("nickname");
          $appTools.delCookie("username");
          $appTools.delCookie("userId");
          location.href=$appData.baseUrl+"login";
        };
        toastr.success("退出成功");
      },
      error:function(){
        //toastr.error($appData.msg.error);
        location.href=$appData.baseUrl+"login";
      }
    });

//  });
}
//切换页面
function togglePage(url){
  $("#pageContent").load(url,function(response,status,xhr){
    // console.log(status);
    if(status=="success"){
      var dataType = $('#subPage').attr('data-type');
      for (key in pageData) {
       if (key == dataType) {
         pageData[key]();
       }
     }
   }else if(status=="error"){
     toastr.error($appData.msg.error);
   }

  });
}
//获取数据列表
function getDataList(id,url,page,listdom=null,msg=''){
  if(listdom!=null){
    var dom = $("#"+listdom);
  }else{
    var dom = $("#data-list")
  }
  console.log(dom);
  $.ajax({
    url:$appData.baseUrl+url,
    data:{
      'size':10,
      'page':page,
    },
    dataType:'json',
    success:function(res){
      //$("#data-total-number").text(res.result.totalElements);
      var data = res.result.content ? res.result.content:res.result;
      console.log(msg);
      if(data.length==0&&msg!=''){
        location.href=$appData.baseUrl+'error/info?msg='+msg;
      }
      var dataList = template(id,data);
      dom.html(dataList);
      auth();
      initPage(id,url,page,res.result.totalPages-1);
    },
    error:function(){
      toastr.error($appData.msg.error);
    }
  });
}
//初始化页码
function initPage(id,url,page,totalPage){
  page = parseInt(page);
  totalPage = parseInt(totalPage);
  var pre = page==0?0:page-1;
  var next = page==totalPage?totalPage:page+1;

  var html = '<ul class="am-pagination tpl-pagination">'
              +'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+pre+')">«</a></li>';
  //console.log(totalPage);
  if(page==0){
    var i=0;
    for(i=0;i<3&&i<=totalPage;i++){
      var j = i+1;
      var active = "";
      if(i==page){
         active= "am-active";
      }
      //console.log(url);
      html = html+'<li  class="'+active+'"><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+i+')">'+j+'</a></li>';
    }
    //console.log(i);
    if(i<=totalPage){
      if(totalPage-i>=1){
         html = html+'<li><a href="#">...</a></li>';
      }
      var total = totalPage+1;
      html = html+'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+totalPage+')">'+total+'</a></li>';
    }

  }else if(page==totalPage){
    if(totalPage-2>=1){
      html = html+'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\',0)">1</a></li>';
      if(totalPage-1>2){
         html = html+'<li><a href="#">...</a></li>';
      }
    }
    for(var i=totalPage-2>0?totalPage-2:0;i<=totalPage;i++){
      var j = i+1;
      var active = "";
      if(i==page){
         active= "am-active";
      }
      html = html+'<li  class="'+active+'"><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+i+')">'+j+'</a></li>';
    }
  }else{
    var i=parseInt(page)-1;
    if(i>=1){
      html = html+'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\',0)">1</a></li>';
      if(i>=2){
         html = html+'<li><a href="#">...</a></li>';
      }
    }
    for(;i<=parseInt(page)+1;i++){
      var j = i+1;
      var active = "";
      if(i==page){
         active= "am-active";
      }
      html = html+'<li  class="'+active+'"><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+i+')">'+j+'</a></li>';
    }
    if(i<=totalPage){
      if(totalPage-i>=1){
         html = html+'<li><a href="#">...</a></li>';
      }
      var total = totalPage+1;
      html = html+'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+totalPage+')">'+total+'</a></li>';
    }

  }

   html = html+'<li><a href="#" onclick="getDataList(\''+id+'\',\''+url+'\','+next+')">»</a></li></ul>';
 //console.log(html);
 $("#data-list-page").html(html);
}
//添加数据
function addData(url,id,listUrl){
  $("#add").click(function(){
    var $modal = $('#add-modal');
    $modal.modal("open");
    $("#add-submit").unbind().click(function(){
      var validata = $appTools.validator("#add-form");
      if(validata){
        $.ajax({
          'url':$appData.baseUrl+url,
          'dataType':'json',
          'data':$("#add-form").serialize(),
          success:function(res){
            if(res.result==1){
              toastr.success("添加成功");
              $modal.modal("close");
              getDataList(id,listUrl,0);
            }
          },
          error:function(){
            toastr.error("添加失败");
          }
        });
      };
    });
  });
}
//删除数据
function deleteData(url,id){
  $appTools.confirm("您确定要删除该记录么?",function(){
    $.ajax({
      url:$appData.baseUrl+url,
      success:function(res){
        if(res.result==null){
          toastr.success("删除成功");
          //console.log($("tr[list-data-id='"+id+"']"));
          $("tr[list-data-id='"+id+"']").hide();
        }else{
          toastr.error("删除失败");
        }
      },
      error:function(){
        toastr.error("删除失败");
      },
    });
  },function(){

  });
}
//编辑数据
function editData(url,data,id,listUrl){
  //console.log(data);
  var $modal = $('#edit-modal');
  $modal.modal("open");
  var from = $("#edit-form");
  var key = null;
  for (key in data) {
    from.find("input[name='"+key+"']").val(data[key]);
  }
  from.find("#edit-submit").unbind().click(function(){

    var validata = $appTools.validator("#edit-form");
    if(validata){
      $.ajax({
        'url':$appData.baseUrl+url,
        'dataType':'json',
        'data':$("#edit-form").serialize(),
        success:function(res){
          if(res.result==1){
            toastr.success("修改成功");
            $modal.modal("close");
            getDataList(id,listUrl,0);
          }else{
            toastr.error("修改失败");
          }
        },
        error:function(){
          toastr.error("修改失败");
        }
      });
    }
  });
}
//导入数据
function importData(url,id,listUrl){
  $("#import").unbind().click(function(){
      var $modal = $('#import-popup');
      $modal.modal("open");
      document.getElementById("doc-form-file").addEventListener("change",function(event){
      var self = this;
      $.ajaxFileUpload({
        // url:$appData.baseUrl+"/stu/new/upload",
        url:$appData.baseUrl+url,
        secureuri: false,
        fileElementId:'doc-form-file',
        dataType:'json',
        success:function(data, status){
          //console.log(data);
          if(data.code==200){
            toastr.success("数据导入成功");
            getDataList(id,listUrl,0);
          }
        },
        error:function(data, status,e){
          //if(data.code==200){
            toastr.success("数据导入成功");
            $modal.modal("close");
            getDataList(id,listUrl,0);
          //}
        }
      });
    });
  });
}
//获取专业
function majorSelect(id=null){
  $.ajax({
    url:$appData.baseUrl+"/major/list",
    data:{
      'size':20,
      'page':0,
    },
    dataType:'json',
    success:function(res){
      var html = '';
      for(var i=0;i<res.result.content.length;i++){
        if(id==res.result.content[i].id){
          html = html+='<option selected value="'+res.result.content[i].id+'">'+res.result.content[i].name+'</option>';
        }else{
          html = html+='<option  value="'+res.result.content[i].id+'">'+res.result.content[i].name+'</option>';
        }

      }
      $(".major-select-data").append(html);
    }
  });
}
//导出数据
function exportData(url){
  var p = '?';
  var input = $(".data-list-input");
  for(var i=0;i<input.length;i++){
    if(input.eq(i).val()!="all"){
      p =p+"&"+input.eq(i).attr("name")+"="+input.eq(i).val();
    }
  }
  console.log($appData.baseUrl+url+p);
  window.open($appData.baseUrl+url+p);
}
//搜素数据
function searchData(id,url){
  var dom = $("#data-list");
  $.ajax({
    url:$appData.baseUrl+url,
    dataType:'json',
    success:function(res){
      if(res.result!=null){
        var data = res.result.content ? res.result.content:res.result;
        var dataList = template(id,data);
        dom.html(dataList);
        auth();
        initPage(id,url,0,res.result.totalPages-1);
      }else{
        toastr.info("没有该数据");

      }
    },
    error:function(){
        toastr.error($appData.msg.error);
    }
  });
}
//跳转
function go(url){
  //window.open($appData.baseUrl+url);
  var height = $(window).height()*0.6+'px';
  var width = $(window).width()*0.6+'px';
  layer.open({
    type: 2,
    title: '窗口',
    shadeClose: true,
    resize:true,
    shade: false,
    maxmin: true, //开启最大化最小化按钮
    area: [width, height],
    content: $appData.baseUrl+url,
  });
}
//选择学生
function selectStudent(stuId){
  $.ajax({
    url:$appData.baseUrl+"selection/teach/choice",
    data:{
      'studentId':stuId,
      'subjectId':$("#subject-id").val(),
    },
    success:function(res){
      if(res.result==1){
        toastr.success("选择成功");
      }else{
        toastr.error(res.result);
      }
    }
  });
}
//内定学生
function selectStudent2(obj){
  var self = $(obj);
  var paperId = self.attr("paper-id");
  $('#select-stu').modal({
       relatedTarget: this,
       onConfirm: function(options) {
         var stuId = $("#studentId").val();
         if(stuId==null || stuId==""){
           toastr.error("请输入学号");
           return;
         }
         $.ajax({
           url:$appData.baseUrl+"selection/privacy/choice",
           data:{
             'username':stuId,
             'subjectId':paperId
           },
           success:function(res){
             if(res.result==1){
               toastr.success("选择成功");
             }else{
               toastr.error(res.result);
             }
           }
         });
       },
       // closeOnConfirm: false,
       onCancel: function() {
       }
     });
}
//选择题目
function selectSubject(subId){
  if($appTools.getCookie("isSelectSuccess")=='true'){
    toastr.error("您已经确选题目，不能再选择");
    return;
  }
  $appTools.confirm("您确定要选择该题目么?",function(){
    $.ajax({
      url:$appData.baseUrl+"selection/stu/choice",
      data:{
        'wish':0,
        'subjectId':subId,
      },
      success:function(res){
        if(res.result==1){
          //appTool.alert("选题成功");
          toastr.success("选题成功");
          togglePage("select");
        }else{
          //appTool.alert("选题失败");
          toastr.error(res.result);
        }
      },
    });
  },function(){

  });
}
//切换老师
function toggleTeac(i,id){
  var items = $(".teacItem");
  items.removeClass("active");
  items.eq(i).addClass("active");
  getDataList('subListTpl','subject/list?teacherId='+id,0,"sub-list");
}
//退选
function quitSelect(id){
  $appTools.confirm("你确定要退选吗?",function(){
    $.ajax({
      url:$appData.baseUrl+"/selection/refund/"+id,
      dataType:'json',
      success:function(res){
        if(res.result==1){
          toastr.success("退选成功");
          togglePage("select");
        }else{
          toastr.error("退选失败");
        }
      },
      error:function(){
        toastr.error($appData.msg.error());
      },
    });
  },function(){

  });

}
//清除数据
function deleteAllData(url){
  $appTools.confirm("你确定要清除所有数据吗？清除后将不可以恢复?",function(){
    $.ajax({
      url:$appData.baseUrl+url,
      success:function(res){
        if(res.msg=='ok'){
          toastr.success("删除成功");
        }else{
          toastr.error("添加失败");
        }
      },
    });
  },function(){

  });
}
//选择学生
function selectTa(stuId){
   var subjectId = $("input[name='subjectId']").val();
   $appTools.confirm("您确定要选择该学生么?",function(){
     $.ajax({
       url:$appData.baseUrl+"selection/privacy/choice",
       data:{
         'username':stuId,
         'subjectId':subjectId
       },
       success:function(res){
         if(res.result==1){
           toastr.success("选择成功");
         }else{
           toastr.error(res.result);
         }
       },
       error:function(){
         toastr.error($appData.msg.error);
       }
     });
   },function(){

   });
}
//
function openSelectTa(choose,majorId,subjectId){
  if(choose==1){
    toastr.info("该题目已确选");
    return ;
  }
  var url = $appData.baseUrl+"paper/selectStudent?mid="+majorId+"&sid="+subjectId;
  var height = $(window).height()*0.6+'px';
  var width = $(window).width()*0.6+'px';
  layer.open({
    type: 2,
    title: '窗口',
    shadeClose: true,
    resize:true,
    shade: false,
    maxmin: true, //开启最大化最小化按钮
    area: [width, height],
    content:url,
  });
}
